//
//  HMGlodSTView.m
//  HowToDo
//
//  Created by 胡坤 on 2017/1/5.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMGlodSTView.h"

#import "HMGoldSentence.h"

@interface HMGlodSTView()
/**
 
 */
@property(nonatomic,strong)UILabel *sourceTextLable;

/**
 
 */
@property(nonatomic,strong)UILabel * sourceNameLable;
@end

@implementation HMGlodSTView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
       
        UIImageView* bg = [[UIImageView alloc]init];
        bg.frame = CGRectMake(20, 44, self.bounds.size.width-40, self.bounds.size.height-88);
        
        bg.contentMode = UIViewContentModeScaleToFill;
        
        bg.image = [UIImage imageNamed:@"verse_white_bg_44x44_"];
        
        [self addSubview:bg];
        
        UILabel *sourceTextLable  = [[UILabel alloc]init];
        
        sourceTextLable.frame = CGRectMake(bg.frame.origin.x+20, bg.frame.origin.y  , bg.bounds.size.width-40, bg.bounds.size.height);
        sourceTextLable.numberOfLines = 0;

        self.sourceTextLable = sourceTextLable;
        
        [self addSubview:sourceTextLable];
        
        
        self.sourceNameLable = [[UILabel alloc]init];
        
        
        
    
    
        [self addSubview:self.sourceNameLable];
        
      

    }
    return self;
}


-(void)setStence:(HMGoldSentence *)stence
{
    _stence = stence;
    
    self.sourceTextLable.text = stence.ebook_sentence;

    self.sourceNameLable.text = [NSString stringWithFormat:@"来源自《 %@ 》",stence.resource_name];
    [self.sourceNameLable sizeToFit];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
       CGFloat height = self.sourceNameLable.bounds.size.height;
        self.sourceNameLable.center = CGPointMake(self.center.x, self.bounds.size.height-height * 0.5);

}
@end
